{include file="header.htm" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-20">
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>优惠券列表</h3>
                <h5>(共{$pager->totalRows}条数据<span style="display: none;"></span>)</h5>
            </div>
            <form class="navbar-form form-inline" id="postForm" action="{:weapp_url('Coupons/select_coupon')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="50" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="搜索优惠券名称...">
                        <input type="submit" class="btn" value="搜索">
                        <i class="iconfont e-sousuo"></i>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="flexigrid  flexigrid-xin">
        
        <div class="tableDiv " style="height: auto;">
        	<div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w60" axis="col0">
                            <div class="">ID</div>
                        </th>
                        <th abbr="ac_id" axis="col4">
                            <div class="">优惠券名称</div>
                        </th>
                        <th abbr="" axis="col6" class="w150">
                            <div class="">优惠规则</div>
                        </th>
                        <th abbr="" axis="col6" class="w80">
                            <div class="tc">优惠券类型</div>
                        </th>
                        <th abbr="" axis="col6" class="w80">
                            <div class="tc">库存</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w60">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                    <tbody class="no-border">
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="no_row">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                    {else/}
                        {volist name="list" id="vo"}
                        <tr>
                            <td class="sign">
                                <div class="">
                                    {$vo.coupon_id}
                                </div>
                            </td>
                            <td>
                                <div class="">
                                    {$vo.coupon_name}
                                </div>
                            </td>
                            <td>
                                <div class="">
                                    {eq name="$vo.coupon_form" value="1"}
                                    满{$vo.conditions_use}减{$vo.coupon_price}
                                    {else /}
                                    {notempty name="$vo.conditions_use"}满{$vo.conditions_use}{else /}无门槛{/notempty}打{$vo.coupon_discount}折
                                    {/eq}
                                </div>
                            </td>
                            <td>
                                <div class="tc">
                                    {if condition='1 == $vo.coupon_type'}
                                    全站通用
                                    {elseif condition='2 == $vo.coupon_type' /}
                                    指定商品
                                    {elseif condition='3 == $vo.coupon_type' /}
                                    指定分类
                                    {/if}
                                </div>
                            </td>
                            <td class="">
                                <div class="tc">{$vo.coupon_stock}</div>
                            </td>
                            <td class="">
                                <div class="tc">
                                    <a onclick="SaveData(this);" class="btn blue" data-coupon_id="{$vo.coupon_id}" data-name="{$vo.coupon_name}" data-condition="{$vo.condition}">
                                        选择
                                    </a>
                                </div>
                            </td>
                        </tr>
                        {/volist}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                {include file="public/page" /}
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });
    });

    //确认选择
    function SaveData(obj) {
        var coupon_id = $(obj).attr('data-coupon_id');
        var coupon_name = $(obj).attr('data-name');
        var condition = $(obj).attr('data-condition');
        parent.$('#coupon_id').val(coupon_id);
        var str = 'ID:'+coupon_id+','+coupon_name+'('+condition+')';
        parent.$('#coupon_content').text(str);
        parent.layer.close(parentObj);
    }
</script>
{include file="footer.htm" /}
